package com.example.sxt_practise.net;

import java.io.IOException;
import java.net.URL;

/**
 * 1.协议 2.域名 3.端口  4.请求资源
 * 互联网三大基石：URL http html
 * @author gaofeng
 * @date 2022年06月09日 21:16
 */
public class UrlTest {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://zone.bz.cn/#/business/detailProducts?productName=%E4%BA%91%E5%B8%85%E4%BA%91%E6%89%8B%E6%9C%BA&canPass=1&id=177708") ;
            System.out.println("协议：" + url.getProtocol());
            System.out.println("域名" + url.getHost());
            System.out.println("端口" + url.getPort());
            System.out.println("文件" + url.getFile());
            System.out.println("路径" + url.getPath());
            System.out.println("查询部分" + url.getQuery());
            System.out.println("锚点" + url.getRef());
            System.out.println("权限部分" + url.getAuthority());
            System.out.println("URL内容"+ url.getContent());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
